from app2 import *
start=time.time()
enh_start = time.time()
img=stillgan('tmp/seg/raw.png')
cv2.imwrite('tmp/seg/enh.png',img)
enh_end = time.time()
print('enh',enh_end-enh_start)
ves_start = time.time()

#ater
pic = Arter('tmp/seg/raw.png')
cv2.imwrite('./tmp/seg/Ater.png', pic)
ater_pic=ater('tmp/seg/raw.png','./tmp/seg/Ater.png')
re = Image.fromarray(ater_pic).convert("RGB")
re.save('tmp/seg/raw_ater.png')
#ater_enh
pic2 = Arter('tmp/seg/enh.png')
cv2.imwrite('./tmp/seg/enh_Ater.png', pic2)
ater_pic2=ater('tmp/seg/enh.png','./tmp/seg/enh_Ater.png')
re2 = Image.fromarray(ater_pic2).convert("RGB")
re2.save('tmp/seg/enh_ater.png')
#vessel
vs=vseg('tmp/seg/raw.png')
img=applyv('tmp/seg/raw.png',vs)
cv2.imwrite('tmp/seg/raw_seg.png', img)
#vessel_enh
vs = vseg('tmp/seg/enh.png')
img = applyv('tmp/seg/enh.png', vs)
cv2.imwrite('tmp/seg/enh_seg.png', img)
ves_end = time.time()
print('ves', ves_end - ves_start)

ill_start = time.time()
listr=['正常','一级','二级','三级','增殖期']
img_r,prob_r,count_r,weight_r=dr_2('tmp/seg/raw.png')
kind_r=listr[np.argmax(prob_r)]
p_r=prob_r[np.argmax(prob_r)]
cv2.imwrite('tmp/seg/dr_r.png', img_r)
img_e,prob_e,count_e,weight_e=dr_2('tmp/seg/enh.png')
kind_e = listr[np.argmax(prob_e)]
p_e = prob_e[np.argmax(prob_e)]
cv2.imwrite('tmp/seg/dr_e.png', img_e)
ill_end = time.time()
print('ill',ill_end-ill_start)
end=time.time()
print('total',end-start)